package top.lshaci.learning.atguigu.interview3.aqs;

/**
 * ObjectWaitNotifyDemo
 *
 * @author lshaci
 * @since 1.0.0
 */
public class ObjectWaitNotifyDemo {

    static Object lock = new Object();

    public static void main(String[] args) {
        new Thread(() -> {
            synchronized (lock) {
                System.err.println(Thread.currentThread().getName() + " ==> IN");
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.err.println(Thread.currentThread().getName() + " ==> OUT");
            }
        }, "A").start();

        new Thread(() -> {
            synchronized (lock) {
                System.err.println(Thread.currentThread().getName() + " ==> 唤醒");
                lock.notify();
            }
        }, "B").start();
    }
}
